﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using LunchRoller.ViewModels;

namespace LunchRoller
{
    public partial class AddOrEditPlace : PhoneApplicationPage
    {
        public AddOrEditPlace()
        {
            InitializeComponent();
            this.DataContext = App.ViewModel;
            App.BindCommand(App.ViewModel.SavePlaceCommand, ApplicationBar.Buttons[0] as ApplicationBarIconButton);
            App.BindCommand(App.ViewModel.HomeCommand, ApplicationBar.Buttons[1] as ApplicationBarIconButton);
        }

        private void JiePangItem_Click(object sender, RoutedEventArgs e)
        {
            var s = ((Button)sender).DataContext as PlaceModel;
            App.ViewModel.AddingOrEditingPlace.Description = s.Description;
            App.ViewModel.AddingOrEditingPlace.Name = s.Name;
            rootPivot.SelectedIndex = 0;
        }

   
    }
}